<!DOCTYPE html>
<html lang="en">
  <head>
      <meta charset="UTF-8">
      <title>json快速入门</title>
    <script type="text/javascript">
        //JSON本质就是JS的对象
        window.onload = function () {
            /*
                myJson就是一个Json对象
             */
            var myJson = {
                "key1": "lmy",  // 字符串
                "key2": 123,    // Number
                "key3": [1, "hello", 2.3],  // 数组
                "key4": {"age": 12, "name": "jack"},  //json对象
                "key5": [      //json数组
                    {"k1": 10, "k2": "milan"},
                    {"k3": 30, "k4": "smith"},
                    "hello"
                ]
            };

            //取出key1
            console.log("key1=", myJson.key1);

            //取出key3
            console.log("key3=", myJson.key3);
            //对key3取出的值(数组)，遍历获取其值
            for (let i = 0; i < myJson.key3.length; i++) {
                console.log("第%i%个元素的值=", i, myJson.key3[i])
            }

            //取出key4
            console.log("key4=", myJson.key4);
            console.log("key4.age=", myJson.key4.age);

            //取出key5
            console.log("key5=", myJson.key5)
            //对key3取出的值(数组)，遍历获取其值
            for (let i = 0; i < myJson.key5.length; i++) {
                console.log("第%i个元素的值=", i, myJson.key5[i])
            }
        }

    </script>
  </head>
  <body>

  </body>
</html>